#coding=utf-8
__author__ = 'czq'
from django import template  #导入模板包
register = template.Library()  #register 的模块级变量，template.Library的实例
@register.filter(name='theme_list_format_url')  # 注册过滤器 name: 过滤器名称，缺省时为函数名(eg: cut)
def theme_list_format_url(request,para):
    #raise Exception,request.GET
    url=request.get_full_path()
    if not url.endswith('&'):
        url=url+"&"
    if url.find("?")==-1:
        return '?'
    if url.find(para)!=-1:
        import re
        url=re.sub('%s=.*?&'%para,'', url)
    return url